cmake_minimum_required(VERSION 3.20)

project(CMake_Pack VERSION 0.1.0 LANGUAGES CXX)

# --测试--
include(CTest)
enable_testing()
# 测试1
add_test(NAME test1 COMMAND Coco)
set_tests_properties(test1 PROPERTIES PASS_REGULAR_EXPRESSION "^Input")

# 添加目标
add_subdirectory(AMath)
add_executable(Coco main.cpp)
target_link_libraries(Coco PRIVATE AMath)

# --安装--
  # 设置安装前缀 
set(CMAKE_INSTALL_PREFIX "D:/")
  # bin
install(TARGETS Coco DESTINATION ${PROJECT_NAME}/bin)
  # include 
file(GLOB_RECURSE Headers ${CMAKE_SOURCE_DIR}/*.h)
install(FILES ${Headers} DESTINATION ${PROJECT_NAME}/include)
  # lib
install(TARGETS AMath DESTINATION ${PROJECT_NAME}/lib)
  # source  
install(DIRECTORY AMath DESTINATION ${PROJECT_NAME}/source)
install(FILES CMakeLists.txt main.cpp DESTINATION ${PROJECT_NAME}/source)


# --打包-- 
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_SOURCE_GENERATOR "ZIP")
include(CPack)